/*************
author:: libo
license:: MIT
*****************/

#ifndef LB_Math_H_
#define LB_Math_H_
#define factorial LB_factorial
#define SIGN(x) ((x>0)?1:((x<0)?-1:0))
#ifndef SAFE_SQRT
#define SAFE_SQRT(x) (x>=0?sqrt(x):0)
#endif
#ifndef SAFE_FREE
#define SAFE_FREE(x) if(x!=NULL){free(x);x=NULL;}
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#ifdef __cplusplus
extern "C" {
#endif
    
int factorial(int);
int * pailie_map_i_to_reverse_order(int);
int* map_reverse_order_to_pailie(int*,int);
int* compute_combination(int,int);

static inline double *out_product(double *a,double *b)
{
    double* re=(double*)malloc(sizeof(double)*3); 
    re[0]=a[1]*b[2]-a[2]*b[1];
    re[1]=-a[0]*b[2]+a[2]*b[0];
    re[2]=a[0]*b[1]-a[1]*b[0];
    return re;
}

double inner_product(double* a,double* b,int len );
int normalize(double *a,int len);


double distance_of_two_points(double * a,double* b,int n);

#ifdef __cplusplus
}
#endif
#endif
#undef factorial
